do DemoWindow.{show-at-center};

do DemoWindow.{on-close}.{connect {os::exit 0}};

do DemoWindow.{on-resize}
    . { connect &{width,height} =>
        { os::println { "Current Size: (?, ?)" (width.{String}, height.{String}) } }
            .{ crash-on-error } };

do
    \ buf := sync { Reactive 'Hello World' },
    \ display := sync { Reactive 'Hello World' },
    { merge [
        (buf connect &(text) =>
            { os::println { "Current Text: ?" text } } .{ crash-on-error }),
        (TextInput bind buf),
        (TextDisplay bind display.{watch}),
        buf.{watch}
            . { debounce 300 }
            . { connect display },
        ChangeTextButton.{activated}
            . { concat-map &() => { gen-random () } }
            . { map &(x) => { String x } }
            . { connect display }
    ] };
